package com.itic.mall.system.threeset.controller;

import java.util.HashMap;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itic.appbase.applications.sys.common.service.OutCommonService;
import com.itic.appbase.applications.sys.syssetting.service.SysSettingService;
import com.itic.appbase.framework.common.constants.IticConst;
import com.itic.appbase.framework.common.constants.ResponseCode;
import com.itic.appbase.framework.common.controller.BaseController;


@Controller
@RequestMapping(value="/system/threeset")
public class ThreesetController
     extends BaseController {
    @Autowired
    private SysSettingService sysSettingService;

    @Autowired
   	protected OutCommonService outCommonService;
       
       //////////////////////////////////////////////////////常量区////////////////////////////////////////////////////////////////
       private static final String MODEL_NAME_CHINA = "三级分销设置";//中文名
       private static final String MODEL_NAME＿ENGLISH = "threeset";//英文名
       private static final String PAGE_COMMON_PATH = "/mall/system/threeset/threeset";//通用路径
       private static final String COMMON_URL = "/system/threeset/";//通用路径


       //////////////////////////////////////////////////////页面跳转区////////////////////////////////////////////////////////////
      
       /*
        * 主页面
        */
       @RequestMapping(value="/init")
       public String init(Model model){
    	    String onePeople = sysSettingService.getByKey("MARKET_SET_ONE_PEOPLE");
    	    String onePercent = sysSettingService.getByKey("MARKET_SET_ONE_PERCENT");
    	    String twoPeople = sysSettingService.getByKey("MARKET_SET_TWO_PEOPLE");
    	    String twoPercent = sysSettingService.getByKey("MARKET_SET_TWO_PERCENT");
    		model.addAttribute("onePeople", onePeople);
    		model.addAttribute("onePercent", onePercent);
    		model.addAttribute("twoPeople", twoPeople);
    		model.addAttribute("twoPercent", twoPercent);
    	    
	       	model.addAttribute("name_china", MODEL_NAME_CHINA);
	       	model.addAttribute("name_english", MODEL_NAME＿ENGLISH);
	       	model.addAttribute("common_url", COMMON_URL);
	       	return PAGE_COMMON_PATH+"Main";
       }
       
       
      

       /**
        * 编辑
        * 
        */
       @RequestMapping(value = "/edit")
       @ResponseBody
       public Map<String, String> edit( String onePeople,String onePercent,String twoPeople,String twoPercent ) {
           Map<String, String> resultMap = new HashMap<String, String>();
           String result = ResponseCode.SERVER_ERROR.getCode();
           
           result = sysSettingService.editThreeset(onePeople,onePercent,twoPeople,twoPercent);
           resultMap.put(IticConst.RESULT, result);
           return resultMap;
       }

}